-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/services refactoring #76
Conversation
WalkthroughThe changes involve refining the navigation system in a React Native application, focusing on import optimizations, named exports utilization, and restructuring the navigation service for enhanced navigator management. Robust testing practices have been integrated to ensure the reliability and functionality of the navigation features. Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (2)
Files skipped from review as they are similar to previous changes (1)
Additional Context UsedGitHub Check Runs (1)
Additional comments not posted (5)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Coverage reportTotal coverage
Report generated by 🧪jest coverage report action from 6d47b4e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
app/navigators/AppNavigator.js
Outdated
@@ -3,7 +3,7 @@ import { createStackNavigator } from '@react-navigation/stack'; | |||
import SplashScreen from '@scenes/SplashScreen/'; | |||
import ExampleScreen from '@scenes/ExampleScreen'; | |||
import { NavigationContainer } from '@react-navigation/native'; | |||
import NavigationService from '../services/NavigationService'; | |||
import { setTopLevelNavigator } from '../services/NavigationService'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use aliases while importing.
So, "@services/NavigationService"
/** | ||
* Test sagas | ||
*/ | ||
|
||
/* eslint-disable redux-saga/yield-effects */ | ||
|
||
import { takeLatest } from 'redux-saga/effects'; | ||
import NavigationService from 'app/services/NavigationService'; | ||
// import NavigationService from 'app/services/NavigationService'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove unused imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has been resolved in rootscreen refactor pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
const NavigationService = '@app/services/NavigationService'; | ||
jest.mock('@app/services/NavigationService', () => ({ | ||
...jest.requireActual('@app/services/NavigationService'), | ||
navigateAndReset: jest.fn() | ||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mock setup for NavigationService
is potentially incorrect.
The mock setup for NavigationService
uses a string instead of the actual module. This could lead to issues where the mock does not behave as expected because it's not linked to the actual module being tested. Consider importing the module and then mocking it.
- const NavigationService = '@app/services/NavigationService';
+ import NavigationService from '@app/services/NavigationService';
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const NavigationService = '@app/services/NavigationService'; | |
jest.mock('@app/services/NavigationService', () => ({ | |
...jest.requireActual('@app/services/NavigationService'), | |
navigateAndReset: jest.fn() | |
})); | |
import NavigationService from '@app/services/NavigationService'; | |
jest.mock('@app/services/NavigationService', () => ({ | |
...jest.requireActual('@app/services/NavigationService'), | |
navigateAndReset: jest.fn() | |
})); |
const method = startup(); | ||
NavigationService.navigateAndReset = submitSpy; | ||
set(NavigationService, 'navigateAndReset', submitSpy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use of set
from Lodash to modify NavigationService
might not affect the mock.
The use of set
to modify NavigationService
in the test might not have the intended effect because the NavigationService
is a mock and its properties might not be settable in this way. Consider directly assigning the spy to the mocked function.
- set(NavigationService, 'navigateAndReset', submitSpy);
+ NavigationService.navigateAndReset = submitSpy;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
set(NavigationService, 'navigateAndReset', submitSpy); | |
NavigationService.navigateAndReset = submitSpy; |
Ticket Link
Related Links
Description
Steps to Reproduce / Test
GIF's
Summary by CodeRabbit
Refactor
Tests
setTopLevelNavigator
function.